package com.laich.springcloud;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.laich.springcloud.dto.UserDTO;
import com.laich.springcloud.entity.SysUser;
import com.laich.springcloud.service.SysUserService;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = UpmsServiceApplication.class)
public class UserTs {
	@Autowired
	SysUserService userService;
	
	@Value("${security.encode.key:1234567812345678}")
	private String encodeKey;

	@Test
	public void tUser() {
		SysUser sysUser = new SysUser();
		sysUser.setUsername("laich");
		SysUser user = userService.list().get(1);
		System.err.println(user.toString());
	}

	@Test
	public void tUser2() {
		SysUser sysUser = new SysUser();
		sysUser.setUsername("laich");
		
		LambdaQueryWrapper<SysUser> qw= Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, "admin");
		SysUser user = userService.getOne(qw);
		System.err.println(user.toString());

		SysUser user2 = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, "admin"));
		System.err.println("===" + user2.toString());
		
		System.out.println("----------"+encodeKey);

	}
	@Test
	public void tPage() {
		Page page  =new Page(1,10);
		IPage ipage = userService.getUserWithRolePage(page, new UserDTO());
		List records = ipage.getRecords();
		
		System.out.println(records.size());
		
	}
	
}
